<template>
  <el-dialog v-drag :title="type === 'add' ? '新增' : '编辑'" :visible.sync="centerDialogVisible" width="700px">
    <el-form ref="form" :model="ruleform" label-width="80px" label-position="left" class="form" :inline="true">
      <el-form-item label="批次号">
        <el-input v-model="ruleform.batch" />
      </el-form-item>
      <el-form-item label="品种" style="margin-left:20px;">
        <el-input v-model="ruleform.kind" />
      </el-form-item>
      <el-form-item label="舍号">
        <el-input v-model="ruleform.number" />
      </el-form-item>
      <el-form-item label="饲养员" style="margin-left: 20px;">
        <el-input v-model="ruleform.staff" />
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="confirm">确 定</el-button>
      <el-button @click="centerDialogVisible = false">取 消</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  name: 'EditOrAdd',
  emits: ['submit'],
  props: {
    type: {
      type: String,
      default: 'add'
    }
  },
  data() {
    return {
      centerDialogVisible: false, // 弹框显示
      ruleform: {
        batch: '',
        number: '',
        kind: '',
        staff: ''
      }
    }
  },
  methods: {
    // 提交
    confirm() {
      this.$emit('submit', { ...this.ruleform })
    }
  }
}
</script>

<style lang="scss" scoped>
.container {
  .form {
    margin: 0px 20px;
  }

  .dialog-footer {
    margin-top: 10px;
  }
}
</style>
